package com.noble.glamour.ui.fragment.video;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.noble.glamour.R;
import com.noble.glamour.third.recyclerholder.BaseRecyclerViewAdapter;
import com.noble.glamour.third.recyclerholder.BaseRecyclerViewHolder;

/**
 * 女性视频集：话题
 * Created by Su on 2017/11/14.
 */
public class VideoIssueAdapter extends BaseRecyclerViewAdapter<String> {
    private int selectPosition;

    @Override
    public int[] getItemLayouts() {
        return new int[]{R.layout.video_issue};
    }

    @Override
    public void onBindRecycleViewHolder(BaseRecyclerViewHolder viewHolder, final int position) {
        final String issue = getItem(position);

        final ImageView iv_choose = viewHolder.findViewById(R.id.iv_choose);
        TextView tv_issue = viewHolder.findViewById(R.id.tv_issue);
        RelativeLayout item_issue = viewHolder.findViewById(R.id.item_issue);

        iv_choose.setVisibility(View.GONE);
        tv_issue.setText(String.valueOf(issue));     // 话题
        item_issue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) { // 选中话题
                iv_choose.setVisibility(View.VISIBLE);
                updateData(position);
            }
        });
    }

    private void updateData(int positon) {
        notifyItemChanged(selectPosition);
        this.selectPosition = positon;
    }

    @Override
    public int getRecycleViewItemType(int position) {
        return 0;
    }
}
